using UnityEngine;

public class OptionsUI : GameUI
{
	public UISprite sprSound;

	public UISprite sprMusic;

	public UILabel lbSound;

	public UILabel lbMusic;
	public UISprite sprSound1;

	public UISprite sprMusic1;

	public UILabel lbSound1;

	public UILabel lbMusic1;

	public UILabel lbLanguage;

	public string[] allLanguages;

	public IAPManager inappManager;

	private void Start()
	{
		checkShowSound();
		checkShowMusic();
		checkShowLanguage();
	}

	private void checkShowSound()
	{
		if (PersistenData.Sound)
		{
			sprSound.color = new Color32(38, 147, 40, byte.MaxValue);
			sprSound1.color = new Color32(38, 147, 40, byte.MaxValue);
			lbSound.text = "On";
			lbSound1.text = "On";
		}
		else
		{
			sprSound1.color = Color.grey;
			sprSound.color = Color.grey;
			lbSound.text = "Off";
			lbSound1.text = "Off";
		}
	}

	private void checkShowMusic()
	{
		if (PersistenData.Music)
		{
			sprMusic1.color = new Color32(38, 147, 40, byte.MaxValue);
			sprMusic.color = new Color32(38, 147, 40, byte.MaxValue);
			lbMusic1.text = "On";
			lbMusic.text = "On";
		}
		else
		{
			sprMusic1.color = Color.grey;
			sprMusic.color = Color.grey;
			lbMusic1.text = "Off";
			lbMusic.text = "Off";
		}
	}

	private void checkShowLanguage()
	{
		lbLanguage.text = allLanguages[PersistenData.Language];
	}

	public void SoundButton()
	{
		Debug.Log("sound button");
		if (PersistenData.Sound)
		{
			PersistenData.Sound = false;
		}
		else
		{
			PersistenData.Sound = true;
		}
		checkShowSound();
	}

	public void MusicButton()
	{
		if (PersistenData.Music)
		{
			PersistenData.Music = false;
		}
		else
		{
			PersistenData.Music = true;
		}
		checkShowMusic();
	}

	public void NextLanguageButton()
	{
		int num = PersistenData.Language + 1;
		if (num >= allLanguages.Length)
		{
			PersistenData.Language = 0;
		}
		else
		{
			PersistenData.Language = num;
		}
		checkShowLanguage();
	}

	public void PrevLanguageButton()
	{
		int num = PersistenData.Language - 1;
		if (num < 0)
		{
			PersistenData.Language = allLanguages.Length - 1;
		}
		else
		{
			PersistenData.Language = num;
		}
		checkShowLanguage();
	}

	public void RestorePurchaseButton()
	{
		UnityEngine.Debug.Log("im restoring");
		inappManager.RestorePurchasedItem();
	}
}
